
<?php

@session_start();

//header("Content-type:text/html;charset=utf-8");

require(dirname(__FILE__) . "/../lib/common.inc");

$s_cid = '';
$username = '';
$s_attitude = '';

if (!isset($_POST['id'])) {
	$s_cid = '';
} else {
	$s_cid = $_POST['id'];
}

if (!isset($_POST['attitude'])) {
	$s_attitude = '';
} else {
	$s_attitude = $_POST['attitude'];
	if ($s_attitude == '支持') {
		$s_attitude = 'support';
	}
	if ($s_attitude == '反对') {
		$s_attitude = 'oppose';
	}
}

if(!isset($_SESSION['username'])){
	$username = '';
} else {
	$username = $_SESSION['username'];
}

$errno = 0;$s_errno = '0';
if (trim($s_cid) == "") $errno = -1;
if ($errno < 0) {
	$s_errno = strval($errno);
	echo("{\"errno\":\"{$s_errno}\"}");
	exit();
}

$errno = add_comment_comment($s_cid, $username, $s_attitude);
$s_errno = strval($errno);
echo("{\"errno\":\"{$s_errno}\"}");

?>
